import { AuthGuard } from './api/auth.guard';
import { RegisterComponent } from './pages/register/register.component';
import { LoginComponent } from './pages/login/login.component';
import { SidebarLayoutComponent } from './pages/sidebar-layout/sidebar-layout.component';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
  {
    path: '',
    component: SidebarLayoutComponent,
    children: [
      { path: '', pathMatch: 'full', redirectTo: '/overview/today' },
      { path: 'overview', loadChildren: () => import('./pages/overview/overview.module').then(m => m.OverviewModule) },
      { path: 'phaseTask', loadChildren: () => import('./pages/phase-task/phase-task.module').then(m => m.PhaseTaskModule) },
      { path: 'period', loadChildren: () => import('./pages/periodic-task/peroidic-task.module').then(m => m.PeroidicTaskModule) },
    ],
    canActivate: [AuthGuard],
    canActivateChild: [AuthGuard]
  },
  { path: 'login', component: LoginComponent },
  { path: 'register', component: RegisterComponent },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
